#ifndef PRINTER_H
#define PRINTER_H


#include <QTextEdit>
class Printer
{
public:
    enum Level{
        L_DEBUG,  //打印信息
        L_INFO,   //有用的信息
        L_WARNING,//警告
        L_ERROR,  //错误
        L_CRITICAL//严重错误
    };
    enum EquipmentType{
        Console,
        TextEdit,
        Label,
        LineEdit,
        PlainTextEdit,
        ToolButton,
        PushButton
    };

    Printer(const Printer&)=delete;
    Printer& operator=(const Printer&)=delete;
    static Printer* init();
    void setLevel(Level type){m_type=type;};
    void print(QTextEdit*,QString,Level level=L_INFO);
    void log(QString msg);
    void log(void* Equipment,QString msg, Level type=L_DEBUG, EquipmentType=Console);
private:
    Printer(){};
    Level m_type = L_INFO;
    QString levelToString(Level level);
    QString getMesg(Level level, QString &text);
};

#endif // PRINTER_H
